﻿using System;
using System.Text;
using System.IO;
using System.Xml.Serialization;
using System.Net;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Windows.Forms;
using Mimoza.Common;
using Mimoza.ObjectLayer;
using Mimoza.NetworkPlugin;

namespace SetupWiz
{
    public partial class NetworkSettings : Form
    {
        public string AdapterInfo
        {
            get 
            {                
                AdapterInfo[] adaptersInfo = new AdapterInfo[1];
                adaptersInfo[0] = new AdapterInfo();
               
                adaptersInfo[0].AdapterID = 0;
                adaptersInfo[0].EnableDHCP4DNS = this.radioButtonDNS1.Checked;
                adaptersInfo[0].EnableDHCP4IP = this.radioButtonIP1.Checked;
                adaptersInfo[0].IPAddress = this.IP.Text;
                adaptersInfo[0].SubNetMask = this.IPSubnet.Text;
                adaptersInfo[0].DefaultGateWay = this.IPGateway.Text;
                adaptersInfo[0].DNS1 = this.DNS1.Text;
                adaptersInfo[0].DNS2 = this.DNS2.Text;

                XmlSerializer serializer = new XmlSerializer(typeof(AdapterInfo[]));
                TextWriter text = new StringWriter();
                serializer.Serialize(text, adaptersInfo);

                return text.ToString();
            }
        }
  
        public NetworkSettings()
        {
            InitializeComponent();
        }

         private void radioButton_CheckedChanged(object sender, EventArgs e)
        {
             this.IP.Enabled = this.radioButtonIP2.Checked;
             this.IPSubnet.Enabled = this.radioButtonIP2.Checked;
             this.IPGateway.Enabled = this.radioButtonIP2.Checked;

             this.DNS1.Enabled = this.radioButtonDNS2.Checked;
             this.DNS2.Enabled = this.radioButtonDNS2.Checked;
        }
    }
}